<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:75:"D:\wamp64\www\weChatPhoto\public/../application/index\view\index\index.html";i:1508122431;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>sama赞赏社</title>
    <link rel="stylesheet" href="/static/css/bootstrap/bootstrap.min.css">
    <script src="/static/js/jquery-3.2.1.js"></script>
    <script src="/static/js/bootstrap/bootstrap.min.js"></script>
</head>
<style>
    .title {
        text-align: center;
        color: #212121;
    }

    .login-info {
        margin-bottom: 20px;
        text-align: center;
    }

    .login-info > img {
        height: 80px;
        width: 80px;
        border-radius: 50%;
    }

    .form-control:focus {
        border: 1px solid #FFB0A9;
    }

</style>
<body>

<div class="container">
    <h4 class="title">登录页</h4>
    <hr style="margin: 0 0 20px 0; color: #e6e7e7;">
    <form class="form-horizontal" role="form" style="margin-bottom: 80px;">
        <div class="form-group login-info">
            <img src="/static/img/sama.png" alt="上传头像">
        </div>

        <div class="form-group">
            <label for="phone" class="col-xs-2 col-sm-2 control-label" style="padding-right: 0;">手机号</label>
            <div class="col-xs-10 col-sm-10" style="padding-left: 5px;">
                <input type="text" class="mobile form-control" id="phone" placeholder="请输入手机号">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword" class="col-xs-2 col-sm-2 control-label" style="padding-right: 0;">密码</label>
            <div class="col-xs-10 col-sm-10" style="padding-left: 5px;">
                <input type="password" class="password form-control" id="inputPassword" placeholder="请输入密码">
            </div>
        </div>

        <div class="form-group" style="text-align: center;">
            <button type="button" class="save btn btn-default" style="margin-bottom: 10px;">登录</button>
            <br>
            <a href="/index/Index/register" style="color: #FFB0A9;">注册账号</a>
        </div>
    </form>
    <div class="message">

    </div>

    <div class="footer" style="text-align: center;">
        <nav class="navbar navbar-default navbar-fixed-bottom">
            <div class="navbar-inner navbar-content-center">
                <p class="text-muted credit" style="padding: 10px;">
                    sama赞赏社 <a style="color: #FFB0A9;" href="/index/Index/samaPrivacy">隐私保护</a>
                </p>
            </div>
        </nav>
    </div>
</div>

<script>
    $('.save').on('click', function () {

        var mobile = $('.mobile').val();
        var password = $('.password').val();

        if (mobile.length != 11 || !(/1(3[0-9]|47|5((?!4)[0-9])|7(0|1|[6-8])|8[0-9])\d{8,8}/.test(mobile))) {
            alert('手机号不正确');
        } else if (password.length == 0 || $.trim(password) == null) {
            alert('密码不能为空');
        } else {
            login(mobile, password);
        }

    })

    function login(mobile, password) {
        $.ajax({
            type: 'post',
            url: '/index/Index/login',
            data: {mobile: mobile, password: password},
            success: function (r) {
                console.log(r);
                if (r.code == 1) {
                    $('.message').html(r.msg);
                    setTimeout("javascript:location.href='/index/Index/selectOpera'", 1);
                } else {
                    $('.message').html(r.msg);
                }
            }
        })
    }

</script>
</body>
</html>